#!usr/bin/python3
#用于classify合并，新分类的train和test移动到老版分类的train和test中
import sys
import getopt
import os
import shutil
import time

def main(argv):
    num = 1626239459343
    dec = """用于classify合并，新分类的train和test移动到老版分类的train和test中
    """
    suffixes = ['.png','.jpeg','.jpg']
    newClassPath = argv[0]  # 新分类的
    # oldClassPath = argv[1]  # 老板分类路径
    for dirpath, dirnames, filenames in os.walk(newClassPath):
        for item in filenames:
            if item[0] == ".":
                continue
            if os.path.splitext(item)[1] in suffixes:
                if len(os.path.splitext(item)[0]) < 6:
                    num = num + 1
                    image = os.path.join(dirpath, item)
                    pox = os.path.splitext(item)[1]
                    print(image)
                    print(image.split('.')[0] + ".xml")
                    print(dirpath + "/" + str(num) + pox)
                    print(dirpath + "/" + str(num) + ".xml")
                    shutil.move(image,dirpath + "/" + str(num) + pox)
                    shutil.move(image.split('.')[0] + ".xml",dirpath + "/" + str(num) + ".xml")



if __name__ == "__main__":
    main(sys.argv[1:])
